#!/bin/bash

if [ ! -n "${1}" ] ; then
	echo "Usage: ${0} <apk dir>"
	exit 0
fi

if [ ! -d $1 ]; then
  echo "Error. Not a valid directory."
  exit
fi

mydir=`pwd`
outlog=${mydir}/appver.txt

cd $1
echo "Apk versions:" >$outlog 2>&1
for file in *.apk ; do
  echo "$file" >>$outlog 2>&1
  ( aapt d --values badging "$file" | grep "package:" ) >>$outlog 2>&1
  echo "" >>$outlog 2>&1
done
cd ${mydir}

echo "Created ${outlog}"
